package com.itshizhan.viewpager2demo

import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.viewpager2.adapter.FragmentStateAdapter

class SlideAdapter (private val activity: AppCompatActivity):FragmentStateAdapter(activity) {
    companion object {
         val datas = arrayOf(
            R.string.page1_text_1,
            R.string.page2_text_2,
            R.string.page2_text_3
        )
    }
    override fun getItemCount(): Int {
        return datas.size
    }


    override fun createFragment(position: Int): Fragment {
        return SlidePageFragment.getInstance(position)
    }

    fun getPageTitle(position: Int): CharSequence? = activity.getString(datas[position])

}